package me.caofeng.pojo;

import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import me.caofeng.enums.ItemStatus;
import me.caofeng.serializer.JsonItemStatusSerializer;

import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import java.util.Date;

/**
 * Copyright © 2017曹峰. All rights reserved.
 *
 * @Prject: mall
 * @Package: me.caofeng.pojo
 * @Description: 商品目录实体
 * @Author: 曹峰 blog.caofeng.me
 * @Date: 2017-06-19 21:02
 * @Version: V1.0
 */
public class Category extends Pojo{

    @NotNull(message = "父分类不能为空")
    private Integer parentId;

    @NotNull(message = "分类名字不能为空")
    @Size(min = 1,message = "名字最少要一个字")
    private String name;

    private ItemStatus status;

    private int sortOrder;

    @NotNull(message = "分类描述不能为空")
    @Size(min = 1,message = "分类描述至少要一个字")
    private String description;

    public Category() {
    }

    public Category(Integer id, Date createTime, Date updateTime, int isDelete, Integer parentId, String name, ItemStatus status, int sortOrder, String description) {
        super(id, createTime, updateTime, isDelete);
        this.parentId = parentId;
        this.name = name;
        this.status = status;
        this.sortOrder = sortOrder;
        this.description = description;
    }

    public Integer getParentId() {
        return parentId;
    }

    public void setParentId(Integer parentId) {
        this.parentId = parentId;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    @JsonSerialize(using = JsonItemStatusSerializer.class)
    public ItemStatus getStatus() {
        return status;
    }

    public void setStatus(ItemStatus status) {
        this.status = status;
    }

    public int getSortOrder() {
        return sortOrder;
    }

    public void setSortOrder(int sortOrder) {
        this.sortOrder = sortOrder;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    @Override
    public String toString() {
        return "Category{" +
                "parentId=" + parentId +
                ", name='" + name + '\'' +
                ", status=" + status +
                ", sortOrder=" + sortOrder +
                ", id=" + id +
                ", description " + description +
                ", createTime=" + createTime +
                ", updateTime=" + updateTime +
                ", isDelete=" + isDelete +
                '}';
    }
}

